package com.koudai.finance.controller;

import com.koudai.finance.service.UserService;
import com.koudai.finance.vo.UserAccountVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.util.Assert;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Description: 公告管理
 * @author: ls
 * @Date: 2020/7/8 16:12
 */
@Api(tags = "用户管理")
@RestController
@RequestMapping("/user")
@Validated
public class UserController {

    @Resource
    private UserService userServiceImpl;

    @ApiOperation(value = "获取账户信息")
    @PostMapping("/getAccount")
    public UserAccountVO getAccount() {
        return userServiceImpl.getAccount();
    }

    @ApiOperation(value = "修改密码")
    @PostMapping("/updatePassword")
    public void updatePassword(String oldPwd, String password) {
        Assert.hasText(oldPwd, "原密码不能为空");
        Assert.hasText(password, "新密码不能为空");
        userServiceImpl.updatePassword(oldPwd, password);
    }

    @ApiOperation(value = "获取充值记录列表")
    @PostMapping("/getTradeList")
    public Map<String, Object> getTradeList() {
        return userServiceImpl.getTradeList();
    }

}
